package com.liao.ticket.vo;

import com.liao.ticket.common.exception.ErrorCode;
import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class Result {
    private boolean success;

    private int code;

    private String msg;

    private String description;

    private Object data;

    public static Result success(Object data){
        return new Result(true, 200, "操作成功", "",data);
    }

    public static Result fail(int code,String msg){
        return new Result(false, code, msg, "",null);
    }

    public static Result fail(ErrorCode errorCode) {
        return new Result(false, errorCode.getCode(), errorCode.getMessage(), errorCode.getDescription(),null);
    }
}
